<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
    <link rel="stylesheet" href="../../assets/libs/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="" id="myForm">
    <div class="layui-form-item">
        <label class="layui-form-label">Id</label>
        <div class="layui-input-block">
            <input type="text" id="uId" name="UId" lay-verify="title" autocomplete="off" placeholder="请输入编号"
                   class="layui-input" readonly>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户姓名</label>
        <div class="layui-input-block">
            <input type="text" id="uName" name="UName" lay-verify="title" autocomplete="off" placeholder="请输入姓名"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" id="uGender1" name="UGender" value="男" title="男" checked>
            <input type="radio" id="uGender2" name="UGender" value="女" title="女">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年龄</label>
        <div class="layui-input-block">
            <input type="text" id="uAge" name="UAge" lay-verify="title" autocomplete="off" placeholder="请输入年龄"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" name="UBirthday" id="date1" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">邮箱</label>
            <div class="layui-input-inline">
                <input type="text" id="uEmail" name="UEmail" lay-verify="email" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">留言</label>
        <div class="layui-input-block">
            <textarea id="uMessage" name="UMessage" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script src="../../assets/libs/layui/layui.js"></script>
<script src="../../assets/js/my.js"></script>
<script>
    layui.use(['form','layer', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery
            , laydate = layui.laydate;
        laydate.render({
            elem: '#date1'
        });
        // form.verify({
        //     title: function(value){
        //         if(value.length < 5){
        //             return '标题至少得5个字符啊';
        //         }
        //     }
        //
        //     ,content: function(value){
        //         layedit.sync(editIndex);
        //     }
        // });
        form.on('submit(demo1)', function (data) {
            layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            });

            $.get(host+'/userservlet/update',data.field,function (r) {
                if(r.code==0){
                    layer.msg("修改成功",{icon:1})

                }else{
                    layer.msg("修改失败",{icon:2})
                }

            });

            // $("#myForm").submit();
            // var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
            // setTimeout(function () {
            //     parent.layer.close(index); // 关闭layer
            // },5);
            })
            // $.post( '/userservlet/update', {
            //     data:data.field
            //     // dataType:'JSON'
            // }, function (r) {
            //     if (r.code == 0) {
            //         layer.msg('修改成功', {icon: 1})
            //     } else {
            //         layer.msg('修改失败', {icon: 2})
            //     }
            // }, 'json')
        });
</script>
</html>